part of 'index.dart';

class ChatHomePage extends StatefulWidget {
  const ChatHomePage({super.key});

  @override
  State<ChatHomePage> createState() => _ChatHomePageState();
}

class _ChatHomePageState extends State<ChatHomePage>
    with SingleTickerProviderStateMixin {
  late final _tabController = TabController(
    length: 2,
    vsync: this,
    animationDuration: Duration.zero,
  );

  @override
  void initState() {
    super.initState();
    ImAPI.giftList();
  }

  @override
  Widget build(BuildContext context) {
    return DecoratedBox(
      decoration: const BoxDecoration(
        color: Color(0xFFDCD4FF),
        // gradient: LinearGradient(
        //   begin: Alignment.topCenter,
        //   end: Alignment.bottomCenter,
        //   stops: [0, 0.12, 1],
        //   colors: [Color(0xFFDCD4FF), Color(0xFFFFFFFF), Color(0xFFFFFFFF)],
        // ),
      ),
      child: Stack(
        children: [
          Column(
            children: [
              SafeArea(
                bottom: false,
                minimum: const EdgeInsets.only(bottom: 10),
                child: Row(
                  children: [
                    Expanded(
                      child: TabBar(
                        controller: _tabController,
                        isScrollable: true,
                        dividerColor: Colors.transparent,
                        tabAlignment: TabAlignment.start,
                        indicatorSize: TabBarIndicatorSize.label,
                        indicatorWeight: 1,
                        indicatorPadding: const EdgeInsets.only(
                            bottom: 6, left: 25, right: 25),
                        overlayColor:
                            const WidgetStatePropertyAll(Colors.transparent),
                        indicator: UnderlineTabIndicator(
                          borderRadius: BorderRadius.circular(99),
                          borderSide: const BorderSide(
                              width: 3.5, color: Color(0xFF8673F6)),
                        ),
                        unselectedLabelStyle: const TextStyle(
                            color: Color(0xFFA198D9), fontSize: 20),
                        labelStyle: const TextStyle(
                          color: Color(0xFF1E1E1E),
                          fontWeight: FontWeight.w700,
                          fontSize: 20,
                        ),
                        tabs: [
                          Tab(text: T.current.c_message),
                          Tab(text: T.current.c_friend)
                        ],
                      ),
                    ),
                    GestureDetector(
                      onTap: () => Get.to(() => const FriendSearchPage()),
                      behavior: HitTestBehavior.opaque,
                      child: Padding(
                        padding: const EdgeInsets.only(right: 13),
                        child: Image.asset(Images.icAddFriend,
                            width: 32, height: 32),
                      ),
                    ),
                  ],
                ),
              ),
              Expanded(
                child: TabBarView(
                  physics: const NeverScrollableScrollPhysics(),
                  controller: _tabController,
                  children: const [ConversationPage(), FriendPage()],
                ),
              ),
            ],
          ),
        ],
      ),
    );
  }
}
